﻿using System;
using System.Collections.Generic;
using UnityEngine;

namespace Function.HotUpdate
{
    public class HotHelper
    {
        public static readonly string Caching = "BundleCacheList";

        [Serializable]
        public class Serialization<T>
        {
            [SerializeField] private List<T> target;

            public List<T> ToList()
            {
                return target;
            }

            public Serialization(List<T> target)
            {
                this.target = target;
            }
        }

        public static string FormatFileSize(long bytes)
        {
            string[] sizes = { "Bytes", "KB", "MB", "GB", "TB" };
            int order = 0;
            while (bytes >= 1024 && order < sizes.Length - 1)
            {
                order++;
                bytes = bytes / 1024;
            }

            return String.Format("{0:0.##} {1}", bytes, sizes[order]);
        }
    }
}